import Vue from 'vue'
import App from './App.vue'
import router from './router/index.js'
import store from './store/index'
import echart from 'echarts'
Vue.config.productionTip = false
import './css/reset.css' // 全局css重置
import './utils/common.js'

import axios from 'axios'
axios.defaults.withCredentials = true

// axios.get('/cas/jwt/token.do').then(res => {
//   if (res && res.status === 200) {
//     let tokens = res.data.returnInfo;
//     sessionStorage.setItem("Authorization", tokens);
//   }
// })
axios.interceptors.request.use(
  config => {
    // 判断是否存在token，如果存在的话，则每个http header都加上token
    let token = sessionStorage.getItem("Authorization");
    if (!config.headers.hasOwnProperty('Authorization') && token) {
      config.headers.Authorization = token;
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  });



import keymaster from 'keymaster'
const bindKeyHandler = (fn) => {
  return () => {
    fn()
    return false
  }
}
export const key = {
  bind: (seed, func) => keymaster(seed, bindKeyHandler(func)),
  ...keymaster,
}
Vue.prototype.$key = key
Vue.prototype.$echarts = echart


import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)

Vue.prototype.$bus = new Vue()

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app')


